﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Microsoft.Xna.Framework.Content;

namespace Tomahawk.Resources.LightningBolts
{
    public class LightningDescriptorReader : ContentTypeReader<LightningDescriptor>
    {
        #region Properties
        public delegate bool InitLightningDescriptorDelegate(LightningDescriptor descriptor);
        public static event InitLightningDescriptorDelegate OnInitLightningDescriptor;
        #endregion

        protected override LightningDescriptor Read(ContentReader input, LightningDescriptor existingInstance)
        {
            LightningDescriptor output = null;

            XmlSerializer x = new XmlSerializer(typeof(LightningDescriptor));
            output = (LightningDescriptor)x.Deserialize(input.BaseStream);

            if (OnInitLightningDescriptor != null)
            {
                OnInitLightningDescriptor(output);
            }

            return output;
        }
    }
}
